#! /bin/sh
#
export custom_url="${custom_url}"
export custom_serverAddr="${custom_serverAddr}"
export custom_serverPort="${custom_serverPort}"
export custom_token="${custom_token}"
export custom_domain="${custom_domain}"
#
if [ -n ${custom_url} ];then
    wget ${custom_url} --no-check-certificate -O /frpc/custom.toml
fi
if [ -f /frpc/custom.toml ];then
    sed -i "s/custom_serverAddr/${custom_serverAddr}/g" /frpc/custom.toml &&
    sed -i "s/custom_serverPort/${custom_serverPort}/g" /frpc/custom.toml &&
    sed -i "s/custom_token/${custom_token}/g" /frpc/custom.toml &&
    sed -i "s/custom_domain/${custom_domain}/g" /frpc/custom.toml &&
    /usr/bin/frpc -c /frpc/custom.toml
else
    /usr/bin/frpc -c /frpc/frpc.toml
fi